<script type="text/javascript">
	//List Configuration
	$j("#list_sportpatient").jqGrid({
		url:'activitypatient/list/<?php echo $parameters["id_patient"];?>',
		datatype:'json',
		mtype:'POST',
		colNames:['Actividad', 'Desde Hace [años]', 'Horas a la semana','Paciente'],
		colModel:[
		          {
			          name:'sport_id',
			          index:'sport_id', 
			          width:30, 
			          editable: true,
			          edittype: 'select',
			          editoptions: {
			          	value:{
			          		<?php
			          		 $sports = $parameters["sports"];				          			 
					  		 $count = count($sports);
					  		 for ($i = 0; $i < $count; $i++){
					  		 	echo $sports[$i]->id.":'".$sports[$i]->sport_name."'";
					  		 	if (($i+1) < $count) echo ",";
					  		 	else echo "";
					  		 }
						    ?>
			          	}
			          }
			      },
		          {
			          name:'age_at_start',
			          index:'age_at_start',
			          width:20, 
			          editable: true,
			          align:"right"
			      },
		          {
			          name:'hours_by_week', 
			          index:'hours_by_week', 
			          width:20,
			          editable: true,
			          align:"right"
			      },
			      {
				      name: 'patient_id',
				      index: 'patient_id',
				      edittype: 'text',
				      editoptions: {value: <?php echo $parameters["id_patient"];?>},
				      width: 10,
				      editable: true,
				      hidden: true
				   }
		],
		pager:'#gridpager_sportpatient',
		loadtext: "Cargando Actividades del Paciente...",
		rowNum:10,
		rowList:[10],
		sortname:'sport_id',
		sortorder:'asc',
		autowidth:true,
		viewrecords:true,
		onSelectRow:function(id){},
		editurl:'activitypatient/save/<?php echo $parameters["id_patient"];?>',
		scrollOffset:0
	});

	$j("#list_sportpatient").setGridWidth("650",true);
	$j("#list_sportpatient").setGridHeight(220);
	
	//Form editing
	$j("#list_sportpatient").jqGrid('navGrid','#gridpager_sportpatient',{
			edit:true,
			add:true,
			del:true,
			search:true},
			{
				closeAfterEdit:true,
				editCaption: "Modificar Actividad de Paciente"
			},
			{
				closeAfterAdd:true,
				addCaption: "Nueva Actividad de Paciente"
			},
			{
				msg: "¿Desea eliminar la actividad seleccionada del paciente?",
				caption: "Eliminar Actividad de Paciente",
				width:350
			});
</script>
